/*
 * $Id$
 *
 * Copyright ( c ) 2014 XuNuo Corporation. All Rights Reserved.
 *
 * This software is the confidential and proprietary information of XuNuo
 * Corporation ("Confidential Information").  You shall not disclose such
 * Confidential Information and shall use it only in accordance with the terms
 * of the license agreement you entered into with XuNuo Corporation or a XuNuo
 * authorized reseller (the "License Agreement"). XuNuo may make changes to the
 * Confidential Information from time to time. Such Confidential Information may
 * contain errors.
 *
 * EXCEPT AS EXPLICITLY SET FORTH IN THE LICENSE AGREEMENT, XuNuo DISCLAIMS ALL
 * WARRANTIES, COVENANTS, REPRESENTATIONS, INDEMNITIES, AND GUARANTEES WITH
 * RESPECT TO SOFTWARE AND DOCUMENTATION, WHETHER EXPRESS OR IMPLIED, WRITTEN OR
 * ORAL, STATUTORY OR OTHERWISE INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A
 * PARTICULAR PURPOSE. XuNuo DOES NOT WARRANT THAT END USER'S USE OF THE
 * SOFTWARE WILL BE UNINTERRUPTED, ERROR FREE OR SECURE.
 *
 * XuNuo SHALL NOT BE LIABLE TO END USER, OR ANY OTHER PERSON, CORPORATION OR
 * ENTITY FOR INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL
 * DAMAGES, OR DAMAGES FOR LOSS OF PROFITS, REVENUE, DATA OR USE, WHETHER IN AN
 * ACTION IN CONTRACT, TORT OR OTHERWISE, EVEN IF XuNuo HAS BEEN ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGES. XuNuo' TOTAL LIABILITY TO END USER SHALL NOT
 * EXCEED THE AMOUNTS PAID FOR THE XuNuo SOFTWARE BY END USER DURING THE PRIOR
 * TWELVE (12) MONTHS FROM THE DATE IN WHICH THE CLAIM AROSE.  BECAUSE SOME
 * STATES OR JURISDICTIONS DO NOT ALLOW LIMITATION OR EXCLUSION OF CONSEQUENTIAL
 * OR INCIDENTAL DAMAGES, THE ABOVE LIMITATION MAY NOT APPLY TO END USER.
 *
 * Copyright version 2.0
 */
package com.th.supcom.pds.config.client.widget;

import java.util.ArrayList;
import java.util.List;

import net.carefx.framework.container.client.constant.FrameworkConstants;
import net.carefx.framework.container.client.context.AppContext;

import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.FieldEvent;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.util.KeyNav;
import com.extjs.gxt.ui.client.widget.Component;
import com.extjs.gxt.ui.client.widget.Info;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.MessageBox;
import com.extjs.gxt.ui.client.widget.Window;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.form.FormButtonBinding;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
import com.extjs.gxt.ui.client.widget.form.Radio;
import com.extjs.gxt.ui.client.widget.form.RadioGroup;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.layout.ColumnData;
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.FormData;
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.th.supcom.framework.dict.web.gwt.client.DictComboBox;
import com.th.supcom.framework.dict.web.gwt.client.model.DictModel;
import com.th.supcom.framework.organization.web.gwt.client.OrgComboBox;
import com.th.supcom.framework.organization.web.gwt.client.model.OrganizationModel;
import com.th.supcom.pds.common.constant.KeysConstants;
import com.th.supcom.pds.common.utils.ClientUtils;
import com.th.supcom.pds.config.client.common.PdsConfigConstant;
import com.th.supcom.pds.config.client.common.PdsConfigEnableEnum;
import com.th.supcom.pds.config.client.common.PdsConfigUtils;
import com.th.supcom.pds.config.client.common.PhamConfigServiceFactory;
import com.th.supcom.pds.config.client.common.PhamWindowConfigModuleEvents;
import com.th.supcom.pds.config.client.model.PhamMachineConfigModel;
import com.th.supcom.pds.config.client.model.PhamWindowConfigModel;
import com.th.supcom.pds.config.client.service.PhamMachineConfigRpcAsync;
import com.th.supcom.pds.config.client.service.PhamWindowConfigRpcAsync;
import com.th.supcom.pds.internal.client.model.PrinterModel;

/**
 * 新增或编辑药房窗口属性
 * 
 * @author wangjian
 */
public class EditPhamWindowConfigWindow extends Window
{
    private static final PhamMachineConfigRpcAsync S_PHAM_MACHINE_CONFIG_RPC_ASYNC = PhamConfigServiceFactory.getPhamMachineConfigService ();
    private static final PhamWindowConfigRpcAsync S_PHAM_WINDOW_CONFIG_RPC_ASYNC = PhamConfigServiceFactory.getPhamWindowConfigService ();

    /** 提交路径. */
    public static final String SCC_BRANCH = "$URL$";
    /** 提交日期. */
    public static final String SCC_LAST_MODIFICATION_DATE = "$Date$";
    /** 最终修改人员. */
    public static final String SCC_LAST_MODIFIER_NAME = "$Author$";
    /** 最终版本号. */
    public static final String SCC_REVISION = "$Revision$";
    private Button m_addButton;
    private Button m_cancelButton;
    /** 核对发药 */
    private DictComboBox m_checkType;
    private Radio m_disableRadio;
    /** 所属药房 */
    private OrgComboBox m_dispensary;
    /** 摆药单打印配置 */
    private PrinterCombox m_dispensePrinter;
    private Radio m_enableRadio;
    /** 启用类型 */
    private RadioGroup m_enableType;
    /** IP地址 */
    private TextField <String> m_ipAddr;
    ListStore <PhamMachineConfigModel> m_machineListStore;

    private PhamWindowConfigModel m_model;

    /** 未摆药单打印机 */
    private PrinterCombox m_notDispensePrinter;

    /** 窗口处方类型 */
    private DictComboBox m_prescType;

    /** 消费凭条打印机 */
    private PrinterCombox  m_rcptPrinter;

    /** 退费申请打印机 */
    private PrinterCombox  m_refundPrinter;

    /** 服务类型 */
    private DictComboBox m_serviceType;

    private final List <Component> m_widgetList = new ArrayList <Component> ();

    /** 窗口名称 */
    private TextField <String> m_windowName;

    /** 退药单打印机 */
    private PrinterCombox  m_withdrawPrinter;

    public EditPhamWindowConfigWindow ()
    {
        m_model = new PhamWindowConfigModel ();
        initUI ();
        registerListeners ();
    }

    public EditPhamWindowConfigWindow (final PhamWindowConfigModel model)
    {
        this.m_model = model;
        initUI ();
        registerListeners ();
    }

    private PhamWindowConfigModel getSaveData ()
    {
        m_model.setDeptCode (m_dispensary.getValue ().getCode ());
        m_model.setDeptPinyinCode (m_dispensary.getValue ().getPinyinCode ());
        m_model.setWindowName (m_windowName.getValue ());
        m_model.setWindowIp (m_ipAddr.getValue ());
        m_model.setServiceType (m_serviceType.getValue ().getDictItemCode ());
        m_model.setOpenFlag (Integer.parseInt (m_enableType.getValue ().getValueAttribute ()));
        m_model.setCheckFlag (Integer.parseInt (m_checkType.getValue ().getDictItemCode ()));
        m_model.setPrescType (Integer.parseInt (m_prescType.getValue ().getDictItemCode ()));
        if (m_rcptPrinter.getValue () != null)
        {
            m_model.setSlipPrinter (m_rcptPrinter.getValue ().getPrinter ());
        }
        if (m_dispensePrinter.getValue () != null)
        {
            m_model.setDispensePrinter(m_dispensePrinter.getValue ().getPrinter ());
        }
        if (m_notDispensePrinter.getValue () != null)
        {
            m_model.setNotDispensePrinter (m_notDispensePrinter.getValue ().getPrinter ());
        }
        if (m_refundPrinter.getValue () != null)
        {
            m_model.setRefundApplyPrinter (m_refundPrinter.getValue ().getPrinter ());
        }
        if (m_withdrawPrinter.getValue () != null)
        {
            m_model.setWithdrawlPrinter (m_withdrawPrinter.getValue ().getPrinter ());
        }

        return m_model;
    }

    private void initLeftContainer (final LayoutContainer left)
    {
        final FormData formData = new FormData ("100%");
        left.setBorders (false);
        left.setStyleAttribute ("paddingRight", "18px");
        final FormLayout layout = new FormLayout ();
        layout.setLabelWidth (95);
        layout.setLabelAlign (LabelAlign.RIGHT);
        left.setLayout (layout);

        m_dispensary = new OrgComboBox ();
        m_dispensary.setFieldLabel (FrameworkConstants.FORM_MUST_FILL_TIP + "药房");
        m_dispensary.setEnabled (false);
        m_dispensary.setTabIndex (1);
        m_dispensary.setAllowBlank (false);
        left.add (m_dispensary, formData);

        m_ipAddr = new TextField <String> ();
        m_ipAddr.setFieldLabel (FrameworkConstants.FORM_MUST_FILL_TIP + "IP地址");
        m_ipAddr.setTabIndex (3);
        m_ipAddr.setAllowBlank (false);
        m_ipAddr.setMaxLength (15);
        left.add (m_ipAddr, formData);

        m_prescType = new DictComboBox (PdsConfigConstant.WINDOW_PRESC_TYPE_DICT_CODE);
        m_prescType.setFieldLabel (FrameworkConstants.FORM_MUST_FILL_TIP + "处方类型");
        m_prescType.setTabIndex (5);
        m_prescType.setAllowBlank (false);
        m_prescType.setEmptyText ("请选择");
        left.add (m_prescType, formData);

        m_enableType = new RadioGroup ();
        m_enableRadio = new Radio ();
        m_disableRadio = new Radio ();
        m_enableRadio.setTabIndex (7);
        PhamConfigWidgetUtils.generateEnableRadio (m_enableType, m_enableRadio, m_disableRadio, "窗口");

        left.add (m_enableType, formData);

        m_machineListStore = new ListStore <PhamMachineConfigModel> ();

        m_rcptPrinter = new PrinterCombox (this);
        setDefualtValue (m_rcptPrinter,"slipPrinter");
        m_rcptPrinter.setFieldLabel ("消费凭条打印机");
        m_rcptPrinter.setEmptyText ("请选择打印机");
        m_rcptPrinter.setTabIndex (9);
        left.add (m_rcptPrinter, formData);

        m_notDispensePrinter = new PrinterCombox (this);
        setDefualtValue (m_notDispensePrinter,"notDispensePrinter");
        m_notDispensePrinter.setFieldLabel ("未摆药单打印机");
        m_notDispensePrinter.setEmptyText ("请选择打印机");
        m_notDispensePrinter.setTabIndex (11);
        left.add (m_notDispensePrinter, formData);

    }

    private void setDefualtValue (PrinterCombox printer,String name)
    {
        PrinterModel model=new PrinterModel ();
        if(m_model.get(name)==null){
            return;
        }
        model.setPrinter (m_model.get(name).toString ());
        printer.setValue (model);
    }

    /**
     * 获取当前药房机器列表
     */
    private void initPrinterList ()
    {
        if (null != m_dispensary.getValue ().getCode () && PdsConfigUtils.isEmpty (m_dispensary.getValue ().getCode ()))
        {
            final PhamMachineConfigModel macModel = new PhamMachineConfigModel ();
            String deptCode=ClientUtils.getOrgModel().getOrgCode();
            macModel.setDeptCode (deptCode);
            EditPhamWindowConfigWindow.S_PHAM_MACHINE_CONFIG_RPC_ASYNC.findPhamMachineConfigByExample (macModel,
                                                                                                       new AsyncCallback <List <PhamMachineConfigModel>> ()
                                                                                                       {

                                                                                                           @Override
                                                                                                           public void onFailure (final Throwable caught)
                                                                                                           {
                                                                                                               MessageBox.alert (PdsConfigConstant.ERROR,
                                                                                                                                 caught.getMessage (),
                                                                                                                                 null);
                                                                                                           }

                                                                                                           @Override
                                                                                                           public void onSuccess (final List <PhamMachineConfigModel> result)
                                                                                                           {
                                                                                                               m_machineListStore.removeAll ();
                                                                                                               m_machineListStore.add (result);
                                                                                                           }
                                                                                                       });
        }
    }

    private void initRightContainer (final LayoutContainer right)
    {
        final FormData formData = new FormData ("100%");
        right.setStyleAttribute ("paddingRight", "18px");
        final FormLayout layout = new FormLayout ();
        layout.setLabelWidth (95);
        layout.setLabelAlign (LabelAlign.RIGHT);
        right.setLayout (layout);

        m_windowName = new TextField <String> ();
        m_windowName.setFieldLabel (FrameworkConstants.FORM_MUST_FILL_TIP + "窗口名称");
        m_windowName.setTabIndex (2);
        m_windowName.setAllowBlank (false);
        m_windowName.setMaxLength (10);
        right.add (m_windowName, formData);

        m_serviceType = new DictComboBox (PdsConfigConstant.WINDOW_SERVICE_TYPE_DICT_CODE);
        m_serviceType.setFieldLabel (FrameworkConstants.FORM_MUST_FILL_TIP + "服务类型");
        m_serviceType.setTabIndex (4);
        m_serviceType.setAllowBlank (false);
        m_serviceType.setEmptyText ("请选择");
        right.add (m_serviceType, formData);

        m_checkType = new DictComboBox (PdsConfigConstant.PHAM_CHECK_DICT_CODE);
        m_checkType.setFieldLabel (FrameworkConstants.FORM_MUST_FILL_TIP + "核对发药");
        m_checkType.setTabIndex (6);
        m_checkType.setAllowBlank (false);
        m_checkType.setEmptyText ("请选择");
        right.add (m_checkType, formData);

        m_dispensePrinter = new PrinterCombox (this);
        setDefualtValue (m_dispensePrinter,"dispensePrinter");
        m_dispensary.setEditable(false);
        m_dispensePrinter.setFieldLabel ("摆药单打印机");
        m_dispensePrinter.setEmptyText ("请选择打印机");
        m_dispensePrinter.setTabIndex (8);
        right.add (m_dispensePrinter, formData);

        m_withdrawPrinter = new PrinterCombox (this);
        setDefualtValue (m_withdrawPrinter,"withdrawlPrinter");
        m_withdrawPrinter.setFieldLabel ("退药单打印机");
        m_withdrawPrinter.setEmptyText ("请选择打印机");
        m_withdrawPrinter.setTabIndex (10);
        right.add (m_withdrawPrinter, formData);

        m_refundPrinter = new PrinterCombox (this);
        setDefualtValue (m_refundPrinter,"refundApplyPrinter");
        m_refundPrinter.setEditable (false);
        m_refundPrinter.setFieldLabel ("退费申请打印机");
        m_refundPrinter.setEmptyText ("请选择打印机");
        m_refundPrinter.setTabIndex (12);
        right.add (m_refundPrinter, formData);
    }

    /**
     * 初始化UI控件.
     * 
     */
    private void initUI ()
    {
        FormPanel addPhamWindowConfigForm;
        // 初始化form panel
        setSize (600, 250);
        setBlinkModal (true);
        setModal (true);
        setResizable (false);
        setButtonAlign (HorizontalAlignment.RIGHT);
        setLayout (new FitLayout ());
        
        addPhamWindowConfigForm = new FormPanel ();
        addPhamWindowConfigForm.setFrame (false);
        addPhamWindowConfigForm.setBodyBorder (false);
        addPhamWindowConfigForm.setBorders (false);
        addPhamWindowConfigForm.setHeaderVisible (false);
        final FormLayout layout = new FormLayout ();
        layout.setLabelWidth (95);
        layout.setLabelAlign (LabelAlign.RIGHT);
        addPhamWindowConfigForm.setLayout (layout);

        final LayoutContainer main = new LayoutContainer ();
        main.setLayout (new ColumnLayout ());

        // 初始化左布局容器
        final LayoutContainer left = new LayoutContainer ();
        initLeftContainer (left);

        // 初始化右布局容器
        final LayoutContainer right = new LayoutContainer ();
        initRightContainer (right);

        main.add (left, new ColumnData (.5));
        main.add (right, new ColumnData (.5));

        final FormData formData = new FormData ("100%");
        addPhamWindowConfigForm.add (main, formData);

        add (addPhamWindowConfigForm);
        m_addButton = new Button ("确定(O)");
        m_addButton.setTabIndex (15);
        m_cancelButton = new Button ("取消(C)");
        m_cancelButton.setTabIndex (16);
        final FormButtonBinding buttonBinding = new FormButtonBinding (addPhamWindowConfigForm);
        buttonBinding.addButton (m_addButton);
        addButton (m_addButton);
        addButton (m_cancelButton);
        m_widgetList.add (m_dispensary);
        m_widgetList.add (m_windowName);
        m_widgetList.add (m_ipAddr);
        m_widgetList.add (m_serviceType);
        m_widgetList.add (m_prescType);
        m_widgetList.add (m_enableRadio);
        m_widgetList.add (m_checkType);
        m_widgetList.add (m_rcptPrinter);
        m_widgetList.add (m_dispensePrinter);
        m_widgetList.add (m_notDispensePrinter);
        m_widgetList.add (m_refundPrinter);
        m_widgetList.add (m_withdrawPrinter);
        m_widgetList.add (m_addButton);
    }

    @Override
    protected void onRender (final Element parent, final int pos)
    {
        super.onRender (parent, pos);
        //setFocusWidget (m_dispensary);
        final OrganizationModel orgModel = new OrganizationModel ();
        orgModel.setCode (ClientUtils.getOrgModel().getOrgCode());
        orgModel.setName (ClientUtils.getOrgModel().getOrgName());
        m_dispensary.setValue (orgModel);
        if (null != m_model.getPhamWindowConfigId ())
        {
            EditPhamWindowConfigWindow.S_PHAM_WINDOW_CONFIG_RPC_ASYNC.getPhamWindowConfigById (m_model.getPhamWindowConfigId (),
                                                                                               new AsyncCallback <PhamWindowConfigModel> ()
                                                                                               {

                                                                                                   @Override
                                                                                                   public void onFailure (final Throwable caught)
                                                                                                   {
                                                                                                       MessageBox.alert (PdsConfigConstant.ERROR,
                                                                                                                         "数据加载失败",
                                                                                                                         null);
                                                                                                   }

                                                                                                   @Override
                                                                                                   public void onSuccess (final PhamWindowConfigModel result)
                                                                                                   {
                                                                                                       m_model = result;
                                                                                                       final OrganizationModel orgModel = new OrganizationModel ();
                                                                                                       orgModel.setCode (result.getDeptCode ());
                                                                                                       orgModel.setName (result.getDeptName ());
                                                                                                       m_dispensary.setValue (orgModel);

                                                                                                       m_windowName.setValue (result.getWindowName ());
                                                                                                       m_ipAddr.setValue (result.getWindowIp ());

                                                                                                       DictModel dictModel = new DictModel ();
                                                                                                       dictModel.setDictItemCode (result.getServiceType ());
                                                                                                       dictModel.setDictItemName (result.getServiceName ());
                                                                                                       m_serviceType.setValue (dictModel);

                                                                                                       dictModel = new DictModel ();
                                                                                                       dictModel.setDictItemCode (result.getPrescType ()
                                                                                                                                  + "");
                                                                                                       dictModel.setDictItemName (result.getPrescTypeName ());
                                                                                                       m_prescType.setValue (dictModel);

                                                                                                       dictModel = new DictModel ();
                                                                                                       dictModel.setDictItemCode (result.getCheckFlag ()
                                                                                                                                  + "");
                                                                                                       dictModel.setDictItemName (result.getCheckName ());
                                                                                                       m_checkType.setValue (dictModel);

                                                                                                       m_enableType.setValue (result.getOpenFlag () == PdsConfigEnableEnum.Enable.getCode () ? m_enableRadio
                                                                                                                                                                                            : m_disableRadio);

                                                                                                       
                                                                                                   }
                                                                                               });
        }
    }

    private void positiveBtnAction (final PhamWindowConfigModel model)
    {
        if (model.getPhamWindowConfigId () == null)
        {
            EditPhamWindowConfigWindow.S_PHAM_WINDOW_CONFIG_RPC_ASYNC.addPhamWindowConfig (model,
                                                                                           new AsyncCallback <Void> ()
                                                                                           {

                                                                                               @Override
                                                                                               public void onFailure (final Throwable caught)
                                                                                               {
                                                                                                   MessageBox.alert (PdsConfigConstant.ERROR,
                                                                                                                     caught.getMessage (),
                                                                                                                     null);
                                                                                               }

                                                                                               @Override
                                                                                               public void onSuccess (final Void result)
                                                                                               {
                                                                                                   Info.display (PdsConfigConstant.INFO,
                                                                                                                 "添加药房窗口成功！");
                                                                                                   fireEvent (PhamWindowConfigModuleEvents.UI_REFRESH);
                                                                                                   hide ();
                                                                                               }
                                                                                           });
        }
        else
        {
            EditPhamWindowConfigWindow.S_PHAM_WINDOW_CONFIG_RPC_ASYNC.modifyPhamWindowConfig (model,
                                                                                              new AsyncCallback <Void> ()
                                                                                              {

                                                                                                  @Override
                                                                                                  public void onFailure (final Throwable caught)
                                                                                                  {
                                                                                                      MessageBox.alert (PdsConfigConstant.ERROR,
                                                                                                                        caught.getMessage (),
                                                                                                                        null);
                                                                                                  }

                                                                                                  @Override
                                                                                                  public void onSuccess (final Void result)
                                                                                                  {
                                                                                                      Info.display (PdsConfigConstant.INFO,
                                                                                                                    "更新药房窗口成功成功！");
                                                                                                      fireEvent (PhamWindowConfigModuleEvents.UI_REFRESH);
                                                                                                      hide ();
                                                                                                  }
                                                                                              });
        }
    }

    /**
     * 注册监听事件.
     * 
     */
    private void registerListeners ()
    {
        m_cancelButton.addSelectionListener (new SelectionListener <ButtonEvent> ()
        {
            @Override
            public void componentSelected (final ButtonEvent ce)
            {
                hide ();
            }
        });
        m_addButton.addSelectionListener (new SelectionListener <ButtonEvent> ()
        {
            @Override
            public void componentSelected (final ButtonEvent ce)
            {
                final PhamWindowConfigModel model = getSaveData ();
                positiveBtnAction (model);
            }

        });
        m_dispensary.addListener (Events.Change, new Listener <FieldEvent> ()
        {

            @Override
            public void handleEvent (final FieldEvent fe)
            {
                initPrinterList ();
            }
        });
        shortCutListener ();
    }

    private void shortCutListener ()
    {
        for (int i = 0; i < m_widgetList.size () - 1; i++)
        {
            final int index = i;
            m_widgetList.get (i).addListener (Events.KeyUp, new Listener <ComponentEvent> ()
            {
                @Override
                public void handleEvent (final ComponentEvent event)
                {
                    if (KeysConstants.VK_ENTER == event.getKeyCode ())
                    {
                        m_widgetList.get (index + 1).focus ();
                        return;
                    }
                }
            });
        }
        new KeyNav <ComponentEvent> (this)
        {
            @Override
            public void onKeyPress (final ComponentEvent ce)
            {
                if (ce.isAltKey ())
                {
                    if (ce.getKeyCode () == KeysConstants.VK_O)
                    {
                        final PhamWindowConfigModel model = getSaveData ();
                        positiveBtnAction (model);
                    }
                    if (ce.getKeyCode () == KeysConstants.VK_C)
                    {
                        hide ();
                    }
                }
            }
        };
    }
}
